import React, { useState, useEffect } from 'react'
import { UdTable, http } from '@/lib'
import apis from '@/apis/CustomerManage'

const SaleProductsAreasTb = function (props) {
  const columns: any = [
    {
      title: "销售区域",
      render: (text, record, index) => `${record.provinceName ? record.provinceName + "/" : ""}${record.cityName ? record.cityName + "/" : ""}${record.districtName ? record.districtName : ""}`
    },
    ['销售物料描述', 'sapMatDescribe'],
    ['物料编码', 'sapMatCode'],
  ]
  // const [data, setData] = useState([])
  // const [quering, setQuering] = useState(false)
  // useEffect(() => {
  //   getData(props.id)
  //   return () => {
  //     setData([])
  //   };
  // }, [props.id])
  // const getData = (id) => {
  //   setQuering(true)
  //   http.get(apis.CustomerProductsRegions,{params:{id}}).then(res=>{
  //     const data = res.data
  //     setData(data)
  //   }).finally(()=>setQuering(false))
  // }
  const data = props.dataSource
  const quering = props.loading
  const { onChange, pagination } = props
  return (
    <UdTable
      rowKey='id'
      columns={columns}
      dataSource={data}
      loading={quering}
      pagination={pagination}
      onChange={onChange}
    />
  )
}

export default SaleProductsAreasTb